import { ref } from "vue";

export const useCountdown = ()=>{
    const countdown = ref(0);

    const countStart = ()=>{
        countdown.value = 60;
        const timer = setInterval(() => {
            countdown.value--;
            if(countdown.value <= 0){
                clearInterval(timer);
            }
          }, 1000);
    }

    return {countStart, countdown}
    
}


    // useEffect(() => {
    //   const timer = setInterval(() => {
    //     countdown.value--;
    //   }, 1000);

    //   return () => {
    //     clearInterval(timer);
    //   };
    // }, []);

    // return {
    //   countdown,
    // };